package com.netafull.adapter;

import java.util.List;

import com.netafull.R;
import com.netafull.analyze.Comment;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class NewsCommentAdapter extends BaseAdapter {

	private Context context;
	private List<Comment> list;
	public NewsCommentAdapter(Context context, List<Comment> list){
		this.context = context;
		this.list = list;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		Comment comment = list.get(arg0);
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.newscomments_list_item, null);
		
		TextView tv_number = (TextView) view.findViewById(R.id.newscommentsno);
		tv_number.setText((getCount()-arg0)+".");
		
		TextView tv_name = (TextView) view.findViewById(R.id.newscommentscontributor);
		tv_name.getPaint().setFakeBoldText(true);
		tv_name.setText(comment.getNickname());
		
		TextView tv_created = (TextView) view.findViewById(R.id.newscommentscreated);
		tv_created.setText(comment.getCreated());
		
		TextView tv_comment = (TextView) view.findViewById(R.id.newscommentscomment);
		tv_comment.setText(comment.getComment());
		return view;
	}

}
